import React, { Component } from 'react';
import './own_course.less'
import LeftTab from '../../../components/left_tab'
import { withRouter } from 'react-router-dom';
class OwnCourse extends Component {

  goCourse = (courseId) => {
    return () => {
      this.props.history.push({
        pathname: '/course-detail',
        search:'courseId='+courseId
      })
    }
  }
  render() {
    const { memberStudyCourse, memberBuyCourse } = this.props
    return (
      <div className="own-course-container">
        <LeftTab>
          <div title="学习足迹">
            <ul>
              {
                memberStudyCourse && memberStudyCourse.length ? memberStudyCourse.map(item => {
                  return <li key={item.id} onClick={this.goCourse(item.studyCourseId)}>
                    <span>{item.studyCourseName}</span>
                    <div>点击学习</div>
                  </li>
                }) : "暂无学习足迹"
              }
            </ul>
          </div>
          <div title="已购课程">
            <ul>
              {
                memberBuyCourse && memberBuyCourse.length ? memberBuyCourse.map(item => {
                  return <li key={item.id} onClick={this.goCourse(item.buyCourseId)}>
                    <span>{item.buyCourseName}</span>
                    <div>点击学习</div>
                  </li>
                }) : '暂无已购课程'
              }
            </ul>
          </div>
        </LeftTab>
      </div>
    );
  }
}

export default withRouter(OwnCourse);